package com.wyj;

import com.wyj.mapper.CommentMapper;
import com.wyj.pojo.Comment;
import org.checkerframework.dataflow.qual.TerminatesExecution;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.*;

/**
 * @author ：wyj
 * @description：TODO
 * @date ：2022/10/30 7:05 下午
 */

@SpringBootTest
@ContextConfiguration(classes = NiukeltApplication.class)
@RunWith(SpringRunner.class)
public class textAddManyComments {

    @Autowired
    CommentMapper commentMapper;

    @Test
    public void textAddComments1() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }

    @Test
    public void textAddComments212() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }


    @Test
    public void textAddComments2() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }


    @Test
    public void textAddComments4() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }

    @Test
    public void textAddComments5() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }

    @Test
    public void textAddComments6() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }

    @Test
    public void textAddComments7() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }

    @Test
    public void textAddComments8() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }

    @Test
    public void textAddComments9() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }

    @Test
    public void textAddComments10() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }


    @Test
    public void textAddComments11() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }

    @Test
    public void textAddComments12() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }

    @Test
    public void textAddComments13() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }

    @Test
    public void textAddComments14() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    } @Test
    public void textAddComments15() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }
    @Test
    public void textAddComments16() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }
    @Test
    public void textAddComments17() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }
    @Test
    public void textAddComments18() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }
    @Test
    public void textAddComments19() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }
    @Test
    public void textAddComments20() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }

    @Test
    public void textAns() {

        for (int i = 0; i < 2000; i++) {
            addMoney();
        }
    }

    @Test
    public void textAns2() {

        for (int i = 0; i < 2000; i++) {
            addMoney();
        }
    }

    @Test
    public void textAns3() {

        for (int i = 0; i < 2000; i++) {
            addMoney();
        }
    }

    public  void addMoney() {
        List<Comment> lists = new ArrayList<>();

        for (int i = 0; i < 30000; i++) {
            Comment comment = new Comment();
            comment.setUserId((int)(Math.random()*150+1));
            comment.setEntityType((int)(Math.random()*3+1));
            comment.setEntityId((int)(Math.random()*300+1));
            comment.setTargetId((int)(Math.random()*150+1));
            comment.setContent("我是吴晓峰"+i);
            comment.setStatus(0);
            comment.setCreateTime(new Date());
            lists.add(comment);
        }
        commentMapper.addComments(lists);
    }


    @Test
    public void textSet() {

        Set<String> set = new TreeSet<>();

        set.add("s14");
        set.add("s1");
        set.add("s3");
        set.add("s6");

        for (String integer : set) {
            System.out.println(integer);
        }
    }

    @Test
    public void textHashMap() {

        Map<String, Integer> map = new TreeMap<>();

        map.put("1s",10);
        map.put("9s",9);
        map.put("8s",8);
        map.put("7s",7);

        for (String s : map.keySet()) {
            System.out.println(s + " " +map.get(s));
        }


    }

}
